package part2;

/**
 * <p>Title: Project 13 part 2</p>
 * <p>Description: CS 235 Project #13 pt. 
 *       Shows how to use the Comparable interface for sorting with enumeration classes.</p>
 * @author Anthony Varghese
 * @date   February 5th 2012
 * @version 1.0
 */

import java.util.Vector;

/**
 * Card class using enumeration classes as in Nino & Hosch pp 250-251
 *
 * @author Nino & Hosch, Anthony Varghese
 */
class Card {
	/**
	 * enumeration classes
	 */
	public enum Suit {
		Clubs, Diamonds, Hearts, Spades;
	}
	public enum Rank { 
		Ace, Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Jack, Queen, King; 
	}
	
	/**
	 * Data members
	 */
	private Suit suit;
	private Rank rank;
	
	// Methods
	public Card( Suit s, Rank r){
		suit = s; rank = r;
	}
	
	public String toString(){
		return rank + " of " + suit;
	}
	
	public int compareTo(Card cardb){
		// First, compare suits
		int suitcompare = suit.compareTo( cardb.suit ); 
		if ( suitcompare < 0 )
			return suitcompare;
		if ( suitcompare > 0)
			return suitcompare;

		// At this point, suitcompare must be == 0
		int rankcompare = 0;
		// check rank

		
		return rankcompare;
	}
}



public class Part2 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// Create an empty Vector
		Vector cards = new Vector();
		
		// Add Card objects to the vector
		cards.add( new Card( Card.Suit.Hearts, Card.Rank.Five ) );
		cards.add( new Card( Card.Suit.Hearts, Card.Rank.Six ) );
		cards.add( new Card( Card.Suit.Clubs, Card.Rank.Five ) );
		cards.add( new Card( Card.Suit.Clubs, Card.Rank.Six ) );
		cards.add( new Card( Card.Suit.Clubs, Card.Rank.Seven ) );
		cards.add( new Card( Card.Suit.Clubs, Card.Rank.Eight ) );
		cards.add( new Card( Card.Suit.Hearts, Card.Rank.Seven ) );
		cards.add( new Card( Card.Suit.Hearts, Card.Rank.Eight ) );
		cards.add( new Card( Card.Suit.Clubs, Card.Rank.Ace ) );
		cards.add( new Card( Card.Suit.Clubs, Card.Rank.Two ) );
		cards.add( new Card( Card.Suit.Clubs, Card.Rank.Three ) );
		cards.add( new Card( Card.Suit.Clubs, Card.Rank.Four ) );

		// Print the cards
		System.out.println( "Original order of cards" );
	    for (Object c : cards)
	    	System.out.println( "   "  + c );
	    		
	    // Sort the cards
	    java.util.Collections.sort( cards );
	    		
	    // Print sorted cards
   		System.out.println( "\n\n\nSorted order of cards" );
   	    for (Object c : cards)
   	    	System.out.println( "   "  + c );
	}
}
